from typing import List

def lower_bound(nums:List[int],target:int) ->int:
    left,right=0,len(nums)-1
    while left<=right:
        mid = (left+right)//2
        if nums[mid]>=target:
            right=mid-1
        else:
            left=mid+1
    return left
class Solution:
    def search(self, nums: List[int], target: int) -> int:
        ans = lower_bound(nums,target)
        if ans==len(nums) or nums[ans]!=target:
            return -1
        return ans